<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSmsLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('sms_logs')) {
            Schema::create('sms_logs', function (Blueprint $table) {
                $table->increments('id')->comment('ID');
                $table->tinyInteger('type')->default(0)->comment('类型(0:短信验证码,1:语音验证码,2:短信消息通知)');
                $table->string('mobile', 16)->comment('手机号');
                $table->string('code', 12)->comment('验证码');
                $table->tinyInteger('checked')->default(0)->comment('是否验证(0:未验证,1:已验证)');
                $table->tinyInteger('status')->default(0)->comment('状态(0:未发送,1:已发送,2:发送失败)');
                $table->string('reason', 255)->default("")->nullable()->comment('失败原因');
                $table->string('remark', 255)->default("")->nullable()->comment('备注');
                $table->integer('operator_id')->default(0)->nullable()->comment('操作人ID');
                $table->json('result_msg')->nullable()->comment('请求接口返回的json数据');
                $table->string('ip', 16)->comment('操作IP');
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sms_logs');
    }
}
